package com.dandelion.admin.service;

import com.dandelion.admin.criteria.OrderListQueryCriteria;
import com.dandelion.admin.dao.OrderDao;
import com.dandelion.admin.domain.OrderItem;
import com.dandelion.admin.domain.OrderListItem;
import com.dandelion.common.dao.auto.mapper.OrderMapper;
import com.dandelion.common.dao.auto.pojo.Order;
import com.rockit.core.pojo.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Allen on 2016/9/5.
 */
@Service
public class OrderService {
    @Autowired
    private OrderDao orderDao;
    @Autowired
    private OrderMapper orderMapper;

    public List<OrderListItem> queryOrderList(OrderListQueryCriteria criteria, Pagination pagination) {
        return orderDao.query(criteria, pagination);
    }

    public int countOrderList(OrderListQueryCriteria criteria) {
        return orderDao.count(criteria);
    }

    public List<OrderItem> getOrderItemsByOrderNo(String orderNo) {
        return orderDao.queryOrderItems(orderNo);
    }

    public Order getOrderById(Long orderId) {
        return orderMapper.selectByPrimaryKey(orderId);
    }

    public void updateExprStatus(Long orderId, Byte status) {
        orderDao.updateExprStatus(orderId, status);
    }

    public void updateExprStatusAndFinished(Long orderId, Byte status) {
        orderDao.updateExprStatusAndFinished(orderId, status);
    }

    public void orderCancel(Long orderId) {
        orderDao.orderCancel(orderId);
    }
}
